1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25\registerctxluafile{mchart}{}
26
27\unprotect
28
29
30
31
32\installcorenamespace {flowchart}
33\installcorenamespace {flowline}
34\installcorenamespace {flowshape}
35\installcorenamespace {flowfocus}
36\installcorenamespace {flowsets}
37\installcorenamespace {flowsplit}
38
39\installsimplecommandhandler \??flowchart {FLOWchart} \??flowchart
40\installsimplecommandhandler \??flowline {FLOWline} \??flowline
41\installsimplecommandhandler \??flowshape {FLOWshape} \??flowshape
42\installsimplecommandhandler \??flowfocus {FLOWfocus} \??flowfocus
43\installsimplecommandhandler \??flowsets {FLOWsets} \??flowsets
44\installsimplecommandhandler \??flowsplit {FLOWsplit} \??flowsplit
45
46\let\setupFLOWcharts\setupFLOWchart
47\let\setupFLOWlines \setupFLOWline
48\let\setupFLOWshapes\setupFLOWshape
49
50
51\setupFLOWcharts
52 [\c!width=12\bodyfontsize,
53 \c!height=7\bodyfontsize,
54 \c!offset=\FLOWlineparameter\c!rulethickness,
55 \c!clipoffset=\bodyfontsize,
56 \c!dx=2\bodyfontsize,
57 \c!dy=2\bodyfontsize,
58 \c!nx=0,
59 \c!ny=0,
60 \c!x=1,
61 \c!y=1,
62 \c!labeloffset=.5\bodyfontsize,
63 \c!commentoffset=.5\bodyfontsize,
64 \c!exitoffset=\zeropoint,
65
66
67
68
69
70
71
72
73
74 \c!rulethickness=.15\bodyfontsize,
75 \c!frame=\v!off]
76
77\setupFLOWlines
78 [\c!corner=\v!round,
79 \c!arrow=\v!yes,
80 \c!dash=\v!no,
81 \c!radius=.375\bodyfontsize,
82 \c!color=FLOWlinecolor,
83 \c!rulethickness=.15\bodyfontsize,
84 \c!offset=\zeropoint]
85
86\setupFLOWshapes
87 [\c!default=action,
88 \c!framecolor=FLOWframecolor,
89 \c!background=\v!color,
90 \c!backgroundcolor=FLOWbackgroundcolor,
91 \c!rulethickness=.15\bodyfontsize,
92 \c!offset=.5\bodyfontsize]
93
94\setupFLOWfocus
95 [\c!framecolor=FLOWfocuscolor,
96 \c!background=\FLOWshapeparameter\c!background,
97 \c!backgroundcolor=\FLOWshapeparameter\c!backgroundcolor,
98 \c!rulethickness=\FLOWshapeparameter\c!rulethickness,
99 \c!offset=\FLOWshapeparameter\c!offset]
100
101\setupFLOWsplit
102 [\c!dx=0,
103 \c!dy=0,
104
105
106
107 \c!nx=3,
108 \c!ny=4]
109
110\unexpanded\def\beforeFLOWsplit{\FLOWsplitparameter\c!before}
111\unexpanded\def\afterFLOWsplit {\FLOWsplitparameter\c!after}
112\unexpanded\def\handleFLOWsplit{\FLOWsplitparameter\c!command}
113
114\definecolor [FLOWfocuscolor] [s=.2]
115\definecolor [FLOWlinecolor] [s=.5]
116\definecolor [FLOWframecolor] [s=.7]
117\definecolor [FLOWbackgroundcolor] [s=.9]
118
119\newtoks\everyFLOWchart
120
121\unexpanded\def\module_charts_process[#name]
122 {\clf_flow_start_chart{#name}}
123
124\unexpanded\def\startFLOWchart
125 {\startnointerference
126 \the\everyFLOWchart
127 \dosingleempty\module_charts_start_chart}
128
129\unexpanded\def\module_charts_start_chart[#name]
130 {\clf_flow_start_chart{#name}}
131
132\unexpanded\def\stopFLOWchart
133 {\clf_flow_stop_chart
134 \stopnointerference}
135
136\unexpanded\def\defineFLOWchart
137 {\dodoubleempty\module_charts_FLOW_define}
138
139\unexpanded\def\module_charts_FLOW_define[#name][#settings]#cells
140 {\startnointerference
141 \the\everyFLOWchart
142 \clf_flow_start_chart{#name}
143 #cells
144 \clf_flow_stop_chart
145 \stopnointerference}
146
147\unexpanded\def\startFLOWcell
148 {\dodoubleempty\module_charts_start_cell}
149
150\unexpanded\def\module_charts_start_cell[#1][#2]
151 {\begingroup
152 \iffirstargument
153 \setupFLOWshape[#1]
154 \fi
155 \ifsecondargument
156 \setupFLOWline[#2]
157 \fi
158 \clf_flow_start_cell
159 shape {
160 rulethickness \dimexpr\FLOWshapeparameter\c!rulethickness\relax
161 default {\FLOWshapeparameter\c!default}
162 framecolor {\FLOWshapeparameter\c!framecolor}
163 backgroundcolor {\FLOWshapeparameter\c!backgroundcolor}
164 }
165 focus {
166 rulethickness \dimexpr\FLOWfocusparameter\c!rulethickness\relax
167 framecolor {\FLOWfocusparameter\c!framecolor}
168 backgroundcolor {\FLOWfocusparameter\c!backgroundcolor}
169 }
170 line {
171 rulethickness \dimexpr\FLOWlineparameter\c!rulethickness\relax
172 radius \dimexpr\FLOWlineparameter\c!radius\relax
173 color {\FLOWlineparameter\c!color}
174 corner {\FLOWlineparameter\c!corner}
175 dash {\FLOWlineparameter\c!dash}
176 arrow {\FLOWlineparameter\c!arrow}
177 offset \dimexpr\FLOWlineparameter\c!offset\relax
178 }
179 \relax
180 \endgroup}
181
182\unexpanded\def\stopFLOWcell
183 {\clf_flow_stop_cell}
184
185\unexpanded\def\FLOWchart
186 {\dodoubleempty\module_charts_process}
187
188\def\module_charts_process[#name][#settings]
189
190 {\bgroup
191 \insidefloattrue
192 \dontcomplain
193 \setupFLOWchart[#settings]
194 \usebodyfontparameter\FLOWchartparameter
195
196
197 \clf_flow_make_chart
198 chart {
199 name {#name}
200 option {\FLOWchartparameter\c!option}
201 backgroundcolor {\FLOWchartparameter\c!backgroundcolor}
202 width \dimexpr\FLOWchartparameter\c!width\relax
203 height \dimexpr\FLOWchartparameter\c!height\relax
204 dx \dimexpr\FLOWchartparameter\c!dx\relax
205 dy \dimexpr\FLOWchartparameter\c!dy\relax
206 offset \dimexpr\FLOWchartparameter\c!offset\relax
207 clipoffset \dimexpr\FLOWchartparameter\c!clipoffset\relax
208
209 dot {\FLOWchartparameter\c!dot}
210 hcompact {\FLOWchartparameter\c!hcompact}
211 vcompact {\FLOWchartparameter\c!vcompact}
212 focus {\FLOWchartparameter\c!focus}
213 autofocus {\FLOWchartparameter\c!autofocus}
214 nx \numexpr\FLOWchartparameter\c!nx\relax
215 ny \numexpr\FLOWchartparameter\c!ny\relax
216 x \numexpr\FLOWchartparameter\c!x\relax
217 y \numexpr\FLOWchartparameter\c!y\relax
218 labeloffset \dimexpr\FLOWchartparameter\c!labeloffset\relax
219 commentoffset \dimexpr\FLOWchartparameter\c!commentoffset\relax
220 exitoffset \dimexpr\FLOWchartparameter\c!exitoffset\relax
221 split {\FLOWchartparameter\c!split}
222 }
223 shape {
224 rulethickness \dimexpr\FLOWshapeparameter\c!rulethickness\relax
225 default {\FLOWshapeparameter\c!default}
226 framecolor {\FLOWshapeparameter\c!framecolor}
227 backgroundcolor {\FLOWshapeparameter\c!backgroundcolor}
228 }
229 focus {
230 rulethickness \dimexpr\FLOWfocusparameter\c!rulethickness\relax
231 framecolor {\FLOWfocusparameter\c!framecolor}
232 backgroundcolor {\FLOWfocusparameter\c!backgroundcolor}
233 }
234 line {
235 rulethickness \dimexpr\FLOWlineparameter\c!rulethickness\relax
236 radius \dimexpr\FLOWlineparameter\c!radius\relax
237 color {\FLOWlineparameter\c!color}
238 corner {\FLOWlineparameter\c!corner}
239 dash {\FLOWlineparameter\c!dash}
240 arrow {\FLOWlineparameter\c!arrow}
241 offset {\FLOWlineparameter\c!offset}
242 }
243
244
245 split {
246 nx \numexpr\FLOWsplitparameter\c!nx\relax
247 ny \numexpr\FLOWsplitparameter\c!ny\relax
248 dx \numexpr\FLOWsplitparameter\c!dx\relax
249 dy \numexpr\FLOWsplitparameter\c!dy\relax
250 command {}
251 marking {\FLOWsplitparameter\c!marking}
252 before {}
253 after {}
254 }
255 \relax
256
257
258 \egroup}
259
260\unexpanded\def\FLOWcharts
261 {\dodoubleempty\FLOW_charts}
262
263\def\FLOW_charts[#name][#settings]
264 {\begingroup
265 \setupFLOWchart[\c!split=\v!yes]
266 \setupFLOWsplit[#settings]
267 \FLOWchart[#name]
268 \endgroup}
269
270\appendtoks
271 \let\name \FLOW_name
272 \let\shape \FLOW_shape
273 \let\destination\FLOW_destination
274 \let\focus \FLOW_focus
275 \let\overlay \FLOW_overlay
276 \let\location \FLOW_location
277 \let\text \FLOW_text
278 \let\label \FLOW_label
279 \overloaded\let\comment \FLOW_comment
280 \let\exit \FLOW_exit
281 \let\connection \FLOW_connection
282 \let\include \FLOW_include
283 \let\figure \FLOW_figure
284
285 \let\connect \FLOW_connection
286 \let\locate \FLOW_location
287
288 \overloaded\let\includeFLOWchart\include
289\to \everyFLOWchart
290
291\unexpanded\def\FLOW_name #name{\clf_flow_set_name{#name}\ignorespaces}
292\unexpanded\def\FLOW_shape #shape{\clf_flow_set_shape{#shape}\ignorespaces}
293\unexpanded\def\FLOW_destination#destination{\clf_flow_set_destination{#destination}\ignorespaces}
294\unexpanded\def\FLOW_focus #focus{\clf_flow_set_focus{#focus}\ignorespaces}
295\unexpanded\def\FLOW_overlay #overlay{\clf_flow_set_overlay{#overlay}\ignorespaces}
296\unexpanded\def\FLOW_location #location{\clf_flow_set_location{#location}\ignorespaces}
297\unexpanded\def\FLOW_figure #figure{\clf_flow_set_figure{#figure}\ignorespaces}
298
299\unexpanded\def\FLOW_text {\dosingleempty\module_charts_FLOW_text}
300\unexpanded\def\FLOW_label {\dosingleempty\module_charts_FLOW_label}
301\unexpanded\def\FLOW_comment {\dosingleempty\module_charts_FLOW_comment}
302\unexpanded\def\FLOW_exit {\dosingleempty\module_charts_FLOW_exit}
303\unexpanded\def\FLOW_connection{\dodoubleempty\module_charts_FLOW_connection}
304\unexpanded\def\FLOW_include {\dodoubleempty\module_charts_FLOW_include}
305
306\unexpanded\def\module_charts_FLOW_text [#align]#text{\clf_flow_set_text{#align}{\detokenize{#text}}\ignorespaces}
307\unexpanded\def\module_charts_FLOW_label [#location]#text{\clf_flow_set_label{#location}{\detokenize{#text}}\ignorespaces}
308\unexpanded\def\module_charts_FLOW_comment [#location]#text{\clf_flow_set_comment{#location}{\detokenize{#text}}\ignorespaces}
309\unexpanded\def\module_charts_FLOW_exit [#location]#text{\clf_flow_set_exit{#location}{\detokenize{#text}}\ignorespaces}
310\unexpanded\def\module_charts_FLOW_connection[#location][#offset]#name{\clf_flow_set_connection{#location}{#offset}{#name}\ignorespaces}
311
312\unexpanded\def\module_charts_FLOW_include [#name][#settings]{
313 \begingroup
314 \getdummyparameters[\c!x=1,\c!y=1,#settings]
315 \clf_flow_set_include{#name}\numexpr\dummyparameter\c!x\relax\numexpr\dummyparameter\c!y\relax{\detokenize{#settings}}
316 \endgroup
317 \ignorespaces
318}
319
320\setvariables
321 [flowcell:text]
322 [n=0,
323 x=1,
324 y=1,
325 realx=1,
326 realy=1,
327 text=,
328 align=,
329 set=\setups{flowcell:text:place}]
330
331\def\FLOWx {\getvariable{flowcell:text}{x}}
332\def\FLOWy {\getvariable{flowcell:text}{y}}
333\def\FLOWrealx{\getvariable{flowcell:text}{realx}}
334\def\FLOWrealy{\getvariable{flowcell:text}{realy}}
335
336\defineoverlay
337 [flowcell:figure]
338 [\overlayfigure{\getvariable{flowcell:text}{figure}}]
339
340\startsetups flowcell:text:place
341 \begingroup
342 \iftrialtypesetting
343 \directsetup{flowcell:text:place:indeed}
344 \else \iflocation
345 \edef\flowcelldestination{\getvariable{flowcell:text}{destination}}
346 \ifx\flowcelldestination\empty
347 \directsetup{flowcell:text:place:indeed}
348 \else
349
350 \letinteractionparameter\c!color\empty
351 \letinteractionparameter\c!contrastcolor\empty
352 \gotobox{\directsetup{flowcell:text:place:indeed}}[\flowcelldestination]
353 \fi
354 \else
355 \directsetup{flowcell:text:place:indeed}
356 \fi \fi
357 \endgroup
358\stopsetups
359
360\startsetups flowcell:text:place:indeed
361 \begingroup
362 \directsetup{flowcell:text:user}
363 \edef\flowcellfigure {\getvariable{flowcell:text}{figure}}
364 \edef\flowcelloverlay{\getvariable{flowcell:text}{overlay}}
365 \edef\flowcellalign {\getvariable{flowcell:text}{align}}
366 \edef\flowcellindex {\getvariable{flowcell:text}{n}}
367 \ifx\flowcellfigure\empty
368 \ifx\flowcelloverlay\empty
369 \expandcheckedcsname{flowcell:}\flowcellalign\empty
370
371 {\getFLOWtext\flowcellindex}
372 \else
373 \expandcheckedcsname{flowcell:}\flowcellalign\empty
374 [\c!background={\flowcelloverlay}]
375
376 {\getFLOWtext\flowcellindex}
377 \fi
378 \else
379 \expandcheckedcsname{flowcell:}\flowcellalign\empty
380 [\c!background=flowcell:figure]
381
382 {\getFLOWtext\flowcellindex}
383 \fi
384 \endgroup
385\stopsetups
386
387\unexpanded\def\doFLOWlabel#1#2#3#4#5
388 {\begingroup
389 \def\FLOWx{#1}
390 \def\FLOWy{#2}
391 \def\FLOWrealx{#4}
392 \def\FLOWrealy{#5}
393 \strut
394 \getFLOWtext{#3}
395 \endgroup}
396
397\unexpanded\def\getFLOWtext#1
398 {\ifcase#1\else\clf_flow_get_text\numexpr#1\relax\fi}
399
400\defineframed
401 [flowcell:base]
402 [\c!offset=\v!overlay,
403 \c!frame=\FLOWchartparameter\c!frame,
404 \c!background=\FLOWchartparameter\c!background,
405 \c!backgroundcolor=\FLOWchartparameter\c!backgroundcolor,
406
407 \c!align=\v!middle,
408 \c!bottom=\vfill,
409 \c!top=\vfill,
410 \c!width=\FLOWchartparameter\c!width,
411 \c!height=\FLOWchartparameter\c!height,
412
413 \c!rulethickness=\zeropoint,
414 \c!framecolor=\FLOWchartparameter\c!framecolor]
415
416\defineframed[flowcell:] [flowcell:base]
417\defineframed[flowcell:l] [flowcell:base][\c!align=\v!flushleft]
418\defineframed[flowcell:r] [flowcell:base][\c!align=\v!flushright]
419\defineframed[flowcell:m] [flowcell:base][\c!align=\v!middle]
420\defineframed[flowcell:c] [flowcell:base][\c!align=\v!middle]
421
422\defineframed[flowcell:t] [flowcell:base][\c!top=]
423\defineframed[flowcell:b] [flowcell:base][\c!bottom=]
424
425\defineframed[flowcell:lt][flowcell:base][\c!top=,\c!align=\v!flushleft]
426\defineframed[flowcell:rt][flowcell:base][\c!top=,\c!align=\v!flushright]
427\defineframed[flowcell:mt][flowcell:base][\c!top=,\c!align=\v!middle]
428\defineframed[flowcell:ct][flowcell:base][\c!top=,\c!align=\v!middle]
429
430\defineframed[flowcell:lb][flowcell:base][\c!bottom=,\c!align=\v!flushleft]
431\defineframed[flowcell:rb][flowcell:base][\c!bottom=,\c!align=\v!flushright]
432\defineframed[flowcell:mb][flowcell:base][\c!bottom=,\c!align=\v!middle]
433\defineframed[flowcell:cb][flowcell:base][\c!bottom=,\c!align=\v!middle]
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503\protect
504
505\continueifinputfile{mchart.mkvi}
506
507\input chrtxml.tex
508
509\usemodule[abr01]
510
511\setupFLOWcharts[option=test]
512\setupFLOWcharts[frame=on]
513\setupinteraction[state=start]
514
515
516
517\startMPinclusions
518 predefined_shapes[101] := fullcircle ;
519\stopMPinclusions
520
521\startFLOWchart[demo]
522 \startFLOWcell[framecolor=darkgray]
523 \name {start}
524 \location {1,1}
525 \shape {action}
526 \text {start}
527 \connection [bl] {one}
528 \stopFLOWcell
529 \startFLOWcell[framecolor=darkred]
530 \name {one}
531
532 \location {2,2}
533
534 \shape {101}
535 \text {first}
536
537 \connection [rt] {two}
538
539
540
541
542 \stopFLOWcell
543 \setupFLOWshapes[framecolor=darkgray]
544 \startFLOWcell
545 \name {two}
546
547 \location {3,3}
548 \shape {action}
549 \text {second}
550 \figure {cow.pdf}
551
552
553
554
555
556 \stopFLOWcell
557\stopFLOWchart
558
559\starttext
560
561\startTEXpage
562
563
564
565
566
567 \FLOWchart[demo]
568
569\stopTEXpage
570
571\startTEXpage
572 \FLOWchart[conversion 10]
573\stopTEXpage
574
575\stoptext
576 |